<?php

class Core_Backend_Component_Design_View_Page_Theme_Create extends Core_Backend_Share_View_Form {

    protected function buildToolbar($toolbar){
    	$group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('design/page_theme/index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.apply'))
        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(NULL, 'apply')."')");
        $group->addButton($this->__('share.button.save'))
        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(NULL, 'save')."')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form){
    	$entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('theme_form')
                ->addHiddenField('id', 'theme[id]');
        $form->addTextboxField($this->__('share.label.name'), 'name', "theme[name]", TRUE)
             	->addRequiredRule();
        $form->addTextboxField($this->__('share.label.title'), 'title', "theme[title]", TRUE)
             	->addRequiredRule();
        $input = $form->addSelectField($this->__('share.label.type'), 'type', "theme[type]", TRUE)
                ->setOption('--', '')
                ->setOption($this->__('design.label.page_theme_index'), 'index')
                ->setOption($this->__('design.label.page_theme_article'), 'article')
                ->setOption($this->__('design.label.page_theme_subject'), 'subject')
                ->setOption($this->__('design.label.page_theme_concessions'), 'concessions')
                ->setOption($this->__('design.label.page_theme_customer'), 'customer')
             	->addRequiredRule();
        $form->addBooleanField($this->__('share.label.enable'), 'enabled', 'template[enabled]');
        if(!is_null($entity)){
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }
}